#include <partical/ParticleGravityAffector.h>

namespace ne
{
    const real ParticleGravityAffector::GRAVITY_ACCELERATION = 9.80665f;

    ParticleGravityAffector::ParticleGravityAffector()
        : ParticleAffector("ParticleGravityAffector")
    {
    }

    ParticleGravityAffector::ParticleGravityAffector(const ParticleGravityAffector &affector)
        : ParticleAffector(affector)
    {
    }

    bool ParticleGravityAffector::affectParticles(ParticleList &particleList, const real interval)
    {
        if (!ParticleAffector::affectParticles(particleList, interval)) return false;

        for (ParticleListIterator it=particleList.begin(); it!=particleList.end(); ++it)
        {
            Particle *pParticle = *it;
            pParticle->force.y -= pParticle->mass * GRAVITY_ACCELERATION;
        }

        return true;
    }

    ParticleGravityAffector::~ParticleGravityAffector()
    {
    }
}
